/**
 * @param {number[]} nums
 * @return {number[][]}
 */

var subsets = function (nums) {
    const res = []
    const len = nums.length
    const subset = []
    dfs(0)

    function dfs(index) {
        res.push(subset.slice())
        for (let i = index; i < len; i++) {
            subset.push(nums[i])
            dfs(i + 1)
            subset.pop()
        }
    }
    return res
};
